import java.io.IOException;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;


public class ManterPropostaDeVendas extends List implements CommandListener{
	
	private static String title = "Proposta de Vendas";
	private ConsultoriaMIDlet midlet;
	private HttpPoster httpPoster;
	private Command voltar, ok;
	private Image propostaImage, alterarProposta, excluitProposta, visualizar;
	
	public ManterPropostaDeVendas(ConsultoriaMIDlet midlet, HttpPoster httpPoster) {
		super(title, List.IMPLICIT);
		
		this.midlet = midlet;
		this.httpPoster = httpPoster;
		try {
			propostaImage = Image.createImage("/shoppingup.png");
			alterarProposta = Image.createImage("/shoppingdown.png");
			excluitProposta = Image.createImage("/shoppingremove.png");
			visualizar = Image.createImage("/shopping.png");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		this.append("Inserir", propostaImage);
		this.append("Alterar", alterarProposta);
		this.append("Excluir", excluitProposta);
		this.append("Visualizar", visualizar);
		this.voltar = new Command("Voltar", Command.BACK, 2);
		//this.confirmar = new Command("Confirmar", Command.OK, 0);
		//this.pesquisarCliente = new Command("Pesquisar Cliente", Command.OK,3);
		
		this.addCommand(voltar);
		this.setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d) {
		if(c == List.SELECT_COMMAND)
		{
			//System.out.println("Passei");
			switch(this.getSelectedIndex())
			{
			case 0:
				midlet.showPesquisarCliente(2);
				break;
			case 1:
				midlet.showPesquisarProposta();
				break;
			case 2:
				midlet.showPesquisarProposta();
				break;
			case 3:
				midlet.showPesquisarProposta();
				break;
			}
			
		}
		if(c == voltar)
		{
			midlet.showMenuScreen();
		}
		
	}

}
